package ai.summer.gateway.config;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.exception.ZuulException;
import org.springframework.stereotype.Component;

/**
 * @author shizhanfu
 */
@Component
public class CustomerFilter extends ZuulFilter {
    @Override
    public String filterType() {
        return "post";
    }

    @Override
    public int filterOrder() {
        return 2;
    }

    @Override
    public boolean shouldFilter() {
//        return true;
        RequestContext ctx = RequestContext.getCurrentContext();
        Object isSuccess = ctx.get("isSuccess");
        System.out.println("customer" + isSuccess);
        if (isSuccess == null)
            return true;
        return (Boolean) isSuccess;
    }

    @Override
    public Object run() throws ZuulException {
        System.out.println("customer filter");
        return null;
    }
}
